Namespace HBBSoft.Pivot
    <System.Serializable()> Public MustInherit Class MeasureDisplayModel

    End Class

    <System.Serializable()> Public NotInheritable Class MeasureDisplayModel_Value
        Inherits MeasureDisplayModel

    End Class


    <System.Serializable()> Public NotInheritable Class MeasureDisplayModel_Image
        Inherits MeasureDisplayModel

        Private _Segments As New SegmentCollection
        Public ReadOnly Property Segments() As SegmentCollection
            Get
                Return _Segments
            End Get
        End Property

        Private _DefaultImageURL As String
        Public Property DefaultImageURL() As String
            Get
                Return _DefaultImageURL
            End Get
            Set(ByVal value As String)
                _DefaultImageURL = value
            End Set
        End Property

        Friend Function GetImageURL(ByVal Value As Object) As String
            Dim sm As Segment
            Dim strImageUrl As String = DefaultImageURL

            Try
                For Each sm In Segments
                    If sm.IsInclude(Value) Then
                        strImageUrl = sm.ImageURL
                    End If
                Next
            Catch ex As Exception

            End Try

            Return strImageUrl
        End Function
    End Class


    <System.Serializable()> Public NotInheritable Class Segment
        Private _BeginValue As Decimal
        Public ReadOnly Property BeginValue() As Decimal
            Get
                Return _BeginValue
            End Get
        End Property

        Private _BeginValueCompareModel As EnumBeginValueCompareModel = EnumBeginValueCompareModel.emBiggishAndEqual
        Public ReadOnly Property BeginValueCompareModel() As EnumBeginValueCompareModel
            Get
                Return _BeginValueCompareModel
            End Get
        End Property

        Private _EndValue As Decimal
        Public ReadOnly Property EndValue() As Decimal
            Get
                Return _EndValue
            End Get
        End Property

        Private _EndValueCompareModel As EnumEndValueCompareModel = EnumEndValueCompareModel.emLesser
        Public ReadOnly Property EndValueCompareModel() As EnumEndValueCompareModel
            Get
                Return _EndValueCompareModel
            End Get
        End Property

        Private _ImageURL As String
        Public ReadOnly Property ImageURL() As String
            Get
                Return _ImageURL
            End Get
        End Property

        Private Sub New()
        End Sub
        Friend Sub New(ByVal BeginValue As Decimal, ByVal BeginValueCompareModel As EnumBeginValueCompareModel, ByVal EndValue As Decimal, ByVal EndValueCompareModel As EnumEndValueCompareModel, ByVal ImageURL As String)
            _BeginValue = BeginValue
            _BeginValueCompareModel = BeginValueCompareModel
            _EndValue = EndValue
            _EndValueCompareModel = EndValueCompareModel
            _ImageURL = ImageURL
        End Sub

        Friend Function IsInclude(ByVal Value As Decimal) As Boolean
            Dim bBeginValue As Boolean = False
            Dim bEndValue As Boolean = False

            Select Case _BeginValueCompareModel
                Case EnumBeginValueCompareModel.emBiggish
                    If Value > _BeginValue Then
                        bBeginValue = True
                    End If
                Case EnumBeginValueCompareModel.emBiggishAndEqual
                    If Value >= _BeginValue Then
                        bBeginValue = True
                    End If
            End Select

            Select Case _EndValueCompareModel
                Case EnumEndValueCompareModel.emLesser
                    If Value < _EndValue Then
                        bEndValue = True
                    End If
                Case EnumEndValueCompareModel.emLesserAndEqual
                    If Value <= _EndValue Then
                        bEndValue = True
                    End If
            End Select

            Return bBeginValue And bEndValue
        End Function
    End Class

    <System.Serializable()> Public NotInheritable Class SegmentCollection
        Inherits System.Collections.CollectionBase

        Default Public Property Item(ByVal Index As Integer) As Segment
            Get
                Return CType(List.Item(Index), Segment)
            End Get
            Set(ByVal value As Segment)
                List.Item(Index) = value
            End Set
        End Property

        Public Sub Add(ByRef value As Segment)
            List.Add(value)
        End Sub

        Public Sub Insert(ByVal Index As Integer, ByRef value As Segment)
            List.Insert(Index, value)
        End Sub

        Public Sub Remove(ByRef value As Segment)
            List.Remove(value)
        End Sub

        Public Function Contains(ByRef value As Segment) As Boolean
            Return List.Contains(value)
        End Function

        Public Function IndexOf(ByRef value As Segment) As Integer
            Return List.IndexOf(value)
        End Function
    End Class

End Namespace
